Skip to content

feat(api-keys): add daily-spending-limit input and column - #432

Open
madroidmaq wants to merge 1 commit into
kittors:devfrom
madroidmaq:feature/daily-spending-limit
Open

feat(api-keys): add daily-spending-limit input and column#432
madroidmaq wants to merge 1 commit into
kittors:devfrom
madroidmaq:feature/daily-spending-limit

Conversation

@madroidmaq

Copy link
Copy Markdown

Summary

为 API Key 编辑对话框新增 per-key 费用限额输入框daily-spending-limit(每日消费上限)以及补上一直缺失的 spending-limit(累计上限),配合 CliRelay 后端 PR kittors/CliRelay#471Closes kittors/CliRelay#442)。

Changes

  • ApiKeyFormFields:权限为「无限制 / 自定义」时显示 spending-limitdaily-spending-limit 两个 float(美元)输入框(step=0.01,placeholder 0 = 无限制)。
  • ApiKeysPage:编辑提交时在「无限制 / 自定义」模式从表单 float 解析这两个限额(不再透传原值)。
  • applyApiKeyPermissionProfile:两个分支都把 daily-spending-limit 置 0(与 spending-limit 一致 —— 费用限额是 per-key,PermissionProfile 不承载)。
  • ApiKeyColumns:新增 dailySpendingLimit 列(复用 formatApiKeySpendingLimit 美元格式化)。
  • i18nzh-CN / en 新增 col_daily_spending_limitdaily_spending_limit_helpform_spending_limitform_daily_spending_limitru 沿用 fallback —— 该语言无 api_keys_page 块)。
  • 测试:新增 daily-spending-limit 列渲染测试。

设计说明

费用限额是 per-key 字段。后端 EffectiveAPIKeyRowWithProfiles 在 key 绑定 PermissionProfile 时会把费用限额置零,因此输入框只在未绑定 profile 的权限模式(「无限制」/「自定义」)下显示并生效。

在「无限制」模式下提交时,会清零其它限制但保留表单填写的费用限额(即「无 profile + 费用限额」)。

Verification

  • tsc --noEmit
  • vitest(api-keys,20 tests)✓
  • oxlint(0 errors)✓
  • vite build

Related

🤖 Generated with Claude Code

Add per-key daily-spending-limit (and the long-missing spending-limit) input fields to the API key edit dialog, a dedicated table column, and i18n entries (zh-CN/en). Mirrors CliRelay backend PR kittors#471 (per-day cost cap that resets daily).

Cost-limit inputs render in Unrestricted/Custom permission modes and are submitted via float parsing. PermissionProfile application zeroes them, consistent with spending-limit (per backend EffectiveAPIKeyRowWithProfiles).

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant